package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.dto.NoteFormDTO;
import com.tianji.learning.domain.dto.UpdateNoteDTO;
import com.tianji.learning.domain.query.LearningNotePageQuery;
import com.tianji.learning.domain.vo.LearningNotePageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.tianji.learning.service.ITjNoteService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;

/**
 * <p>
 * </p>
 *
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/notes")
public class TjNoteController {


    @Autowired
    private ITjNoteService tjNoteService;

    /*
     * @Description: 用户端分页查询笔记
     * @Author: 张先冉
     * @Date: 2024-07-28
     */
    @ApiOperation("用户端分页查询笔记")
    @GetMapping("/page")
    public PageDTO<LearningNotePageVo> page(LearningNotePageQuery query) {
        return tjNoteService.pageQuery(query);
    }

    @ApiOperation("新增笔记")
    @PostMapping
    public void saveNote(@RequestBody NoteFormDTO dto){
        tjNoteService.saveNote(dto);
    }

    @PutMapping("/{id}")
    public void updateNoteById(@PathVariable("id")Long id, @RequestBody UpdateNoteDTO dto){
        tjNoteService.updateNoteById(id,dto);
    }

    @DeleteMapping("{id}")
    public void deleteNote(@PathVariable("id")Long id){
        tjNoteService.deleteNote(id);
    }


    @ApiOperation("采集笔记接口")
    @PostMapping("gathers/{id}")
    public void getTjNote(@PathVariable Long id) {
        tjNoteService.gatherTjNote(id);
        //tjNoteService.gatherTjNote(id);


    }
    @ApiOperation("取消采集")
    @DeleteMapping("gathers/{id}")
    public void cancelTjNote(@PathVariable Long id) {
        tjNoteService.cancelTjNote(id);
    }

}
